#ifndef TRADING_WIDGET_HPP
#define TRADING_WIDGET_HPP

#include "trading_system.hpp"
#include <QDoubleSpinBox>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QMessageBox>
#include <QPushButton>
#include <QSpinBox>
#include <QString>
#include <QVBoxLayout>
#include <QWidget>

class TradingWidget : public QWidget {
  Q_OBJECT

public:
  explicit TradingWidget(TradingSystem *tradingSystem,
                         QWidget *parent = nullptr);

public slots:
  void onStockSelected(const QString &stockCode, const QString &stockName,
                       double price);
  void onAccountUpdated();

private slots:
  void onBuyClicked();
  void onSellClicked();
  void updateTotalCost();

private:
  void setupUI();
  void setupConnections();
  void updateBalanceDisplay();

private:
  TradingSystem *m_tradingSystem;

  // 交易信息
  QString m_currentStockCode;
  QString m_currentStockName;
  double m_currentStockPrice;

  // UI元素
  QLabel *m_stockInfoLabel;
  QLabel *m_balanceLabel;
  QSpinBox *m_sharesSpinBox;
  QLabel *m_totalCostLabel;
  QPushButton *m_buyButton;
  QPushButton *m_sellButton;
};

#endif // TRADING_WIDGET_HPP
